    <style>
        .pointer { cursor: pointer}
        .pointer span { display: block}
        .pointer input {  display: none}
        table { text-align: center}
    </style>
    <!-- content start -->
    <div class="admin-content">
        @if (session('status'))
            <div class="am-alert am-alert-success" data-am-alert="">
                <button type="button" class="am-close">×</button>
                <p>{{ session('status') }}</p>
            </div>
        @endif
        <div class="pageheader">
            <h1 class="pagetitle">系统设置</h1>
        </div>
        <div class="am-g">
            <div class="am-u-sm-12">
                <table class="am-table am-table-striped am-table-hover table-main">
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>分组</th>
                        <th>标题</th>
                        <th>字段</th>
                        <th>值</th>
                        <th>备注</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($data as $v)
                        <tr>
                            <td>{{ $v->id }}</td>
                            <td>{{ $v->group_id }}</td>
                            <td class="pointer"><span>{{ $v->title }}</span>{{ Form::text('title', null, ['class'=>'inp', 'data'=>'title-'.$v->id]) }}</td>
                            <td>{{ $v->field }}</td>
                            <td class="pointer"><span>{{ $v->value }}</span>{{ Form::text('value', null, ['class'=>'inp',  'data'=>'value-'.$v->id]) }}</td>
                            <td class="pointer"><span>{{ $v->remark }}</span>{{ Form::text('remark', null, ['class'=>'inp',  'data'=>'remark-'.$v->id]) }}</td>
                        </tr>
                    @endforeach
                    <tr>
                        <td></td>
                        <td>{{ Form::text('group_id', null, ['id'=>'group_id']) }}</td>
                        <td>{{ Form::text('title', null, ['id'=>'title']) }}</td>
                        <td>{{ Form::text('field', null, ['id'=>'field']) }}</td>
                        <td>{{ Form::text('value', null, ['id'=>'value']) }}</td>
                        <td>{{ Form::text('remark', null, ['id'=>'remark']) }}
                            <button class="am-btn am-btn-default am-btn-xs am-text-secondary"><span
                                        class="am-icon-pencil-square-o"></span>添加
                            </button>
                        </td>
                    </tr>
                    </tbody>
                </table>
                <div class="am-cf">
                    共{{ $data->total() }}条记录
                    <div class="am-fr">
                        {!! $data->appends($uri)->render() !!}
                    </div>
                </div>
            </div>
        </div>
        <!-- content end -->
            <script src="http://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
            <script>
                $(".am-btn").click(function () {
                    var title = $("#title").val();
                    var field = $("#field").val();
                    var value = $("#value").val();
                    var remark = $("#remark").val();
                    var group_id = $("#group_id").val();
                    if(title.length<2)
                    {
                        alert("请输入标题");
                        return false;
                    }
                    if(field.length<2)
                    {
                        alert("请输入字段");
                        return false;
                    }
                    if(value.length<2)
                    {
                        alert("请输入值");
                        return false;
                    }
                    $.ajax({
                        type: 'post',
                        url: '{{action('Admin\SysConfigController@postAdd')}}',
                        data: {
                            group_id: group_id,
                            title: title,
                            field: field,
                            value: value,
                            remark: remark,
                            _token: "{{ csrf_token() }}"
                        },
                        async: false,  //默认异步
                        cache: false,  //清除缓存
                        dataType: 'json',
                        success: function (data) {
                            if (data) {
                                window.location.reload(true);
                            }
                        },
                        error: function (){
                            alert('添加失败');
                        }


                    });
                });
                $(".pointer").on("click", function () {
                    $(this).children("input").css("display", "block").focus().val($(this).children("span").text());
                    $(this).children("span").css("display", "none");
                });
                $(".inp").on("blur", function(){
                    var datas = $(this).attr("data");
                    var oldval = $(this).siblings("span").text();
                    var newval = $(this).val() ? $(this).val() : $(this).siblings("span").text();
                    $(this).css("display", "none");
                    $(this).siblings("span").css("display", "block").text(newval);

                    if(oldval == newval){
                        return;
                    }
                    $.ajax({
                        type: 'post',
                        url: '{{action('Admin\SysConfigController@postUpdate')}}',
                        data: {
                            datas:datas,
                            value: newval,
                            _token: "{{ csrf_token() }}"
                        },
                        async: false,  //默认异步
                        cache: false,  //清除缓存
                        dataType: 'json',
                        success: function (data) {
                            if (data) {
                                alert('修改成功');
                            }
                        },
                        error: function (){
                            alert('修改失败');
                        }


                    });
                })
            </script>

